﻿<UserControl x:Class="CaliburnWpf.Views.BankAccountView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             xmlns:vm="clr-namespace:CaliburnWpf.ViewModels;assembly=CaliburnWpf.ViewModels"
             d:DesignHeight="290" d:DesignWidth="382" 
             d:DataContext="{x:Static Member=vm:DesignTimeViewModelSupplier.BankAccount}">    
    
    <UserControl.Resources>
        <ContextMenu x:Key="filterMenu" ItemsSource="{Binding FilterList}" DisplayMemberPath="Title" >
            <ContextMenu.Resources>
                <Style TargetType="MenuItem">
                    <EventSetter Event="Click" Handler="MenuItem_Click"/>
                </Style>
            </ContextMenu.Resources>
        </ContextMenu>
        <Color x:Key="Blue">Blue</Color>
    </UserControl.Resources>
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <StackPanel>
            
            <StackPanel Orientation="Horizontal" >
               
                <TextBlock Text="Account View: " FontSize="18"/>
                <TextBlock Text="{Binding Name}" FontSize="18"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <Grid  Width="16" Height="16" Mouse.MouseDown="Grid_MouseDown">
                    
                    <Ellipse Stroke="Silver" Fill="Transparent" ContextMenu="{StaticResource filterMenu}" StrokeThickness="3">
                        <Ellipse.Effect>
                            <BlurEffect KernelType="Box" Radius="2" />
                        </Ellipse.Effect>
                        <Ellipse.Style>
                            <Style TargetType="Ellipse">
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">

                                    <Trigger.EnterActions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetProperty="Opacity"
                  To="0.25" Duration="0:0:0.2" />
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.EnterActions>
                                    <Trigger.ExitActions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetProperty="Opacity"
                  To="1" Duration="0:0:0.2" />
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.ExitActions>
                                </Trigger>
                            </Style.Triggers>
                            </Style>
                        </Ellipse.Style>
                    </Ellipse>
                    
                    <TextBlock Text=">"  HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Grid>
                <TextBlock Text="View "/>
                <TextBlock Text="{Binding Path=Filter.Title}"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="Account balance: $"></TextBlock>
                <TextBlock Text="{Binding AccountBalance}"/>
                <TextBlock Text="    "/>
                <TextBlock Text="Reconciled balance: $"></TextBlock>
                <TextBlock Text="{Binding ReconciledBalance}"/>
            </StackPanel>
        </StackPanel>
        <DataGrid  Background="White" AutoGenerateColumns="False" EnableRowVirtualization="True" AlternatingRowBackground="AliceBlue" ItemsSource="{Binding Path=Transactions}" Name="transactionSetDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" Grid.Row="1" CanUserAddRows="False" IsReadOnly="True" IsSynchronizedWithCurrentItem="True">
            <DataGrid.Columns>
                <DataGridTemplateColumn x:Name="accountColumn" Header="Account" Width="SizeToHeader">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Path=FromAccount.Name}" Foreground="Red"/>
                                <TextBlock Text="->"/>
                                <TextBlock Text="{Binding Path=ToAccount.Name}" Foreground="Green"/>
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn x:Name="statusColumn"  Header="Status" Width="SizeToHeader" >
                    <DataGridTextColumn.Binding>
                        <Binding Path="Status" >
                            <!--<Binding.Converter>
                                <vm:TransactionStatusConverter/>
                            </Binding.Converter>-->
                        </Binding>
                    </DataGridTextColumn.Binding>
                </DataGridTextColumn>
                <DataGridTextColumn x:Name="idColumn" Binding="{Binding Path=Id}" Header="Id" Width="SizeToHeader" />

                <DataGridTemplateColumn x:Name="categoryColumn" Header="Category" Width="Auto">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Path=Category.Name}" />
                                <TextBlock Text=" : "/>
                                <TextBlock Text="{Binding Path=SubCategory.Name}" />
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTextColumn x:Name="amountColumn" Binding="{Binding Path=Amount}" Header="Amount" Width="SizeToHeader" />
                <DataGridTemplateColumn x:Name="dateColumn" Header="Date" Width="Auto">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Path=Date,StringFormat=\{0:d\}}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn x:Name="contragentColumn" Binding="{Binding Path=Contragent.Name}" Header="Contragent" Width="SizeToHeader" />
                
            </DataGrid.Columns>
        </DataGrid>
        <Grid Grid.Row="2">
            <Grid.Resources>
                <Style TargetType="Button" >
                    <Setter Property="Margin" Value="10,4"/>
                </Style>
            </Grid.Resources>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
				<ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button  x:Name="New" IsEnabled="{Binding CanCreateNew}">
            	<Button.Foreground>
            		<SolidColorBrush Color="{DynamicResource Green}"/>
            	</Button.Foreground>New</Button>
            <Button Grid.Column="1" x:Name="Edit">
            	<Button.Foreground>
            		<SolidColorBrush Color="{DynamicResource Edit}"/>
            	</Button.Foreground>Edit</Button>
            <Button Grid.Column="2" x:Name="Delete">
            	<Button.Foreground>
            		<SolidColorBrush Color="{DynamicResource Red}"/>
            	</Button.Foreground>Delete</Button>
				
				<Button Grid.Column="3" Command="{Binding MoveCommand}">
            	<Button.Foreground>
            		<SolidColorBrush Color="{DynamicResource Blue}"/>
            	</Button.Foreground>Move</Button>
        </Grid>
    </Grid>
</UserControl>
